/**
 * Created by hcadmin on 16/10/24.
 */
$(function(){
    //获取来自管理日历的参数
    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
    })(jQuery);

    var turnDay           = $.getUrlParam('turnDay');
    if(turnDay!=undefined){
        localStorage.turnDay = turnDay;
    }
    //权限管理
    var role = localStorage.role;

    if(role!="3"){
        $(".add_model").remove();
        $(".log_nav_right").text("").unbind('click');
    }else{
        //点击管理
        $(".log_nav_right").on('click',function(){
            window.location.href='logAdministration.html'
        });
    }
    //数据加载
    initLogModelList(localStorage.group_id,"1","0");
    //点击模板
    $(document).on('click','.table_big',function(){
        var dailyrecord_temp_id = $(this).attr("id");
        if(dailyrecord_temp_id){
            window.location.href = "showLogModel.html?id="+dailyrecord_temp_id+"";
        }else {
            window.location.href='addLogModel.html';
        }
    });

    //进入报表界面时 传递 参数 src 用于判断 横竖屏
    $(document).on('click','.report_form',function(){
        var goLogReportForm;
        goLogReportForm                 = document.createElement('iframe');
        goLogReportForm.style.display   = 'none';
        goLogReportForm.id              = 'goReport';
        document.documentElement.appendChild(goLogReportForm);
        goLogReportForm.src = "/goLogReportForm_goCrossScreen";
        //$("#goReport").remove();
        window.location.href='reportForm.html';
    });


    //返回
    var exit;
    exit = document.createElement('iframe');
    exit.style.display = 'none';
    document.documentElement.appendChild(exit);
    $("#log_back").on('click',function(){
        if(localStorage.turnDay!=undefined){
            window.location.href = '../../manageCalendars/calendar.html?turnDay='+localStorage.turnDay+'';
            localStorage.removeItem("turnDay");
        }else{
            exit.src = "/exit2home";
        }
    });
});